<h2>Lead Notes</h2>  
<?php 
    $this->headTitle('Lead Notes');
    $acl = $this->acl;
    $lead_id = $this->escape($this->leadId);
?>

<?php if  ($acl->isAllowed($this->currentUser, 'access lead pages')): ?>
<a href="<?php echo $this->url(array(
        'module'        =>  'default',
        'controller'    =>  'lead',
        'action'        =>  'viewdetails',
        'lead_id'    =>  $lead_id,
    ));?>">Lead</a>
|
<?php endif; ?>

<?php if  ($acl->isAllowed($this->currentUser, 'access lead pages')): ?>
<a href="<?php echo $this->url(array(
        'module'        =>  'default',
        'controller'    =>  'lead',
        'action'        =>  'createnote',
        'lead_id'    =>  $lead_id,
    ));?>">Create note</a>
<?php endif; ?>


<div class="clearing">
&nbsp;
</div>
<?php
if (count($this->paginator)): ?>
<p>
Total number of notes : <?php echo $this->paginator->getAdapter()->count(); ?>
</p>

<table class="data_table">
<tr>
<th class="short">Notes</th>
<th class="mediumshort">Created</th>
<th class="mediumshort">Created by</th>
</tr>
<?php foreach ($this->paginator as $item): ?>
<?php
    $itemsArray = $item->toArray();
?>
<tr>
    <?php 
        echo "<td>";
        $notes = $this->escape($itemsArray['notes']);
        echo nl2br($notes);
        echo "</td>";

        echo "<td>";
        echo $this->escape($this->timestampToHuman($itemsArray['created']));
        echo "</td>";
        
        echo "<td>";
        echo $this->userHyperlink($this->escape($itemsArray['created_by']));
        echo "</td>";
        

    ?>
</tr>

<?php endforeach; ?>
<?php endif; ?>

</table>

<?php echo $this->paginationControl($this->paginator, 'Sliding', 'search.phtml'); ?>
